|
|
Vincent LE CHEVALIER <gal### [at] libertysurffr> wrote:
> Thomas de Groot wrote:
> > OK. Time for one of my stupid questions.
> >
> > From one function, I want to render an isosurface as well as a height_field,
> > following Mike Williams' tutorial. After some trial and error, I obtain the
> > image posted here. The problem is that the height_field (to the right) is
> > not centered at exactly the same location as the isosurface (to the left).
> > And I am unable to find out why, or what I should do about it. I am sure the
> > answer is ridiculously simple and if a gentle soul could help me in my
> > darkness, I would be most grateful :-)
> >
> > I shall post the scene file in p.b.s-f under the same name.
> >
> > Thanks (many!)
> >
> > Thomas
> >
> >
> >
>
> The problematic code is :
>
> [...]
> isosurface {
> function {y - P(x, 0, 1-z)}
> [...]
>
> which you can replace with
>
> [...]
> isosurface {
> function {y - P(x, 0, -z)}
> [...]
>
> which works fine :-) Amazing what a nasty char can do...
>
> The explanation is that you just want to reverse the z-axis to be
> coherent with the height field. By writing P(x, 0, 1-z) not only do you
> reverse the z axis, but you translate it as well...
>
> Hope this helps
>
> --
> Vincent
Here is a general code to illustrate the principle of the conversion HF <->
ISO:
#include "colors.inc"
#include "functions.inc"
global_settings {
assumed_gamma 1.0
}
// ----------------------------------------
camera {
location <0.0, 10, -30.0>
direction 1.5*z
right x*image_width/image_height
look_at <0.0, 0.0, 0.0>
}
background {Gray10}
light_source {
<0, 0, 0> // light's position (translated below)
color rgb <1, 1, 1> // light's color
translate <-30, 30, -30>*100
}
// ----------------------------------------
##declare TERRAIN_SIZE = 10;
#declare TERRAIN_HEIGHT = 2;
#declare fn_Terrain = function (x, y, z) {f_agate (x, 0, z)} // Or whatever
in x-z plane. For functions in x-y plane (wood): f_wood(x, z, 0)
#declare O_ISOTerrain = isosurface
{
function {y - TERRAIN_HEIGHT*fn_Terrain(x/TERRAIN_SIZE, 0,
z/TERRAIN_SIZE)}
max_gradient 4
contained_by {box {<-TERRAIN_SIZE, 0, -TERRAIN_SIZE>, <TERRAIN_SIZE,
TERRAIN_HEIGHT,TERRAIN_SIZE>}}
}
#declare O_HFTerrain = height_field
{
function 300, 300 {fn_Terrain ((x-0.5)*2, 0, -(y-0.5)*2)}
smooth
translate -x/2 -z/2
scale <2*TERRAIN_SIZE,TERRAIN_HEIGHT,2*TERRAIN_SIZE>
}
// Superimpose the 2 versions to check they are close one to another
object {O_ISOTerrain pigment {Red}}
object {O_HFTerrain pigment {Green}}
Bruno
Post a reply to this message
|
|